package com.bush.mall.ware.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.ware.entity.WareSkuEntity;
import com.bush.mall.ware.service.WareSkuService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 商品库存
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("waresku")
@Api(tags = "商品库存管理" )
public class WareSkuController {

    @Resource(name= WareSkuService.BEAN_ID)
    private WareSkuService wareSkuService;

    /**
     * 分页查询商品库存列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询商品库存列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return wareSkuService.queryForPage(current,size);
    }

    /**
     * 保存商品库存表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存商品库存表单")
    @PostMapping
    public Result saveWareSku(@RequestBody WareSkuEntity wareSku){
        return wareSkuService.saveWareSku(wareSku);
    }

    /**
     * 修改商品库存表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改商品库存表单")
    @PutMapping
    public Result updateWareSku(@RequestBody WareSkuEntity wareSku){
        return wareSkuService.updateWareSku(wareSku);
    }

    /**
     * 通过指定id删除商品库存
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除商品库存")
    @DeleteMapping
    public Result deleteWareSku(Long id){
        return wareSkuService.deleteWareSku(id);
    }

}
